package util.android.widgets;

import util.android.ViewUtil;
import util.android.form.respuesta.EditTextInput;

import com.androidutil.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class StringView 
extends AbstractView1<EditTextInput,StringView>
{
	private LinearLayout lyHorizontal;
	private TextView tvTexto;
	
	public StringView(Context context, AttributeSet attrs) {
		super(context, attrs);		
		
		//etiqueta = Util.getAttributo("title",attrs);
		//valor = Util.getAttributo("subtitle",attrs);
	}
	
	@Override
	protected void procesarAtributosPersonalizados(Context context, AttributeSet attrs) {
		super.procesarAtributosPersonalizados(context, attrs);
		
		TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.AbstractView, 0, 0);
	    try {
	        String s = ta.getString(R.styleable.AbstractView_texto);
	        tvTexto.setText(s);
	    } finally {
	        ta.recycle();
	    }
	}
	
	
	
	@Override
	protected EditTextInput crearInput_agregarVistas() {		
		lyHorizontal = (LinearLayout) View.inflate(getContext(), R.layout.view_string, null);
		tvTexto = (TextView) lyHorizontal.findViewWithTag("texto");
		
		EditTextInput inValor = new EditTextInput( (EditText) lyHorizontal.findViewWithTag("editText"));
		inValor.getView().setText("");
		inValor.setSoloLectura(false);
		procesarTextView(inValor.getView());
		ViewUtil.addViewMatch_Wrap(this.getLayoutRespuesta(), lyHorizontal);
		return inValor;	
	}
	
	protected void procesarTextView(TextView view) {
		
	}

	public StringView setEtiquetaId_Valor(int etiquetaID, String valor) throws Exception {
		setEtiquetaByStringId(etiquetaID)
		.getInput().setValor(valor);
		return this;
	}


	public LinearLayout getLayoutHorizontal() {
		return lyHorizontal;
	}


		
}
